<?php
class Cube extends CActiveRecord {
	public static function model($className=__CLASS__)	{
		return parent::model($className);
	}
	public function getDbConnection() {
		$db = Yii::app()->controller->module->db;
      return Yii::createComponent($db);
	}
	public function tableName() {
		return 'cube';
	}
	public function rules()	{
		return array(
			array('dimensions', 'required'),
			array('count', 'numerical', 'integerOnly'=>true),
			array('dimensionstext', 'length', 'max'=>30),
			array('value, sum', 'length', 'max'=>18),
			array('id, dimensions, dimensionstext, value, sum, count', 'safe', 'on'=>'search'),
		);
	}
	public function relations() {
		return array(
		);
	}
	public function attributeLabels() {
		return array(
			'id' => 'ID',
			'dimensions' => 'Dimensions',
			'dimensionstext' => 'Dimensionstext',
			'value' => 'Value',
			'sum' => 'Sum',
			'count' => 'Count',
		);
	}
	public function search() {
		$criteria=new CDbCriteria;
		$criteria->compare('id',$this->id);
		$criteria->compare('dimensions',$this->dimensions,true);
		$criteria->compare('dimensionstext',$this->dimensionstext,true);
		$criteria->compare('value',$this->value,true);
		$criteria->compare('sum',$this->sum,true);
		$criteria->compare('count',$this->count);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}